<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let initial = ['foo']
    let array = ['bar']
    // 虽然是undefined，但是默认情况下会被打平
    // console.log(array[Symbol.isConcatSpreadable])
    const newArray = initial.concat(array)
    // console.log(newArray)
    array[Symbol.isConcatSpreadable] = false;
    // console.log(initial.concat(array))
    // 注意这种类数组对象，默认情况下不会被打平，除非设置为true
    let arrayLikeObject = {
      length: 1,
      0: "baz",
    }
    // arrayLikeObject[Symbol.isConcatSpreadable] = true
    console.log(initial.concat(arrayLikeObject))
    let otherObject = new Set().add('qux')
    // console.log(initial.concat(otherObject))
    otherObject[Symbol.isConcatSpreadable] = true
    console.log(initial.concat(otherObject))
    console.log([1, 2, 3, 4].concat([5, 6, 7]).concat(10))
  </script>
</body>

</html>